From 0f31a1a69526fd09ec355a7f8b1ea2f8c75b2700 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 24 Nov 2004 10:27:49 +0000 Subject: [PATCH] Have Title::makeTitle() do the space to underscore replacement so it can be used on user_text fields directly without fuss. --- includes/Title.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index d79aa5cd69..2d7f17c090 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -172,6 +172,9 @@ class Title { * Create a new Title from a namespace index and a DB key. * It's assumed that $ns and $title are *valid*, for instance when * they came directly from the database or a special page name. + * For convenience, spaces are converted to underscores so that + * eg user_text fields can be used directly. + * * @param int $ns the namespace of the article * @param string $title the unprefixed database key form * @return Title the new object @@ -183,9 +186,9 @@ class Title { $t->mInterwiki = ''; $t->mFragment = ''; $t->mNamespace = IntVal( $ns ); - $t->mDbkeyform = $title; + $t->mDbkeyform = str_replace( ' ', '_', $title ); $t->mArticleID = ( $ns >= 0 ) ? -1 : 0; - $t->mUrlform = wfUrlencode( $title ); + $t->mUrlform = wfUrlencode( $t->mDbkeyform ); $t->mTextform = str_replace( '_', ' ', $title ); return $t; } -- 2.20.1